Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

advisor: use json for package database #4999

Merged
merged 7 commits into from
Apr 9, 2018

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Apr 5, 2018

This PR also simplifies the code a bit by using advisor.Package to be stored in json instead of a helper "snapInfo" struct.

Based on #4845

return err
}
}
sil = append(sil, Package{Snap: snapName, Version: version})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No summary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, I should add a comment. For the mapping of command->snap we do not need the summary, nothing is using that. But that is confusing so a comment is needed here.

@bboozzoo
Copy link
Collaborator

bboozzoo commented Apr 6, 2018

----------------------------------------------------------------------
FAIL: catalogrefresh_test.go:92: catalogRefreshTestSuite.TestCatalogRefresh

catalogrefresh_test.go:112:
    c.Check(dump, DeepEquals, map[string]string{
        "foo": `[{"name":"foo","version":"1.0"}]`,
        "bar": `[{"name":"bar","version":"2.0"}]`,
        "meh": `[{"name":"foo","version":"1.0"},{"name":"bar","version":"2.0"}]`,
    })
... obtained map[string]string = map[string]string{"bar":"[{\"snap\":\"bar\",\"version\":\"2.0\"}]", "foo":"[{\"snap\":\"foo\",\"version\":\"1.0\"}]", "meh":"[{\"snap\":\"foo\",\"version\":\"1.0\"},{\"snap\":\"bar\",\"version\":\"2.0\"}]"}
... expected map[string]string = map[string]string{"foo":"[{\"name\":\"foo\",\"version\":\"1.0\"}]", "bar":"[{\"name\":\"bar\",\"version\":\"2.0\"}]", "meh":"[{\"name\":\"foo\",\"version\":\"1.0\"},{\"name\":\"bar\",\"version\":\"2.0\"}]"}

OOPS: 370 passed, 1 FAILED

Copy link
Collaborator

@bboozzoo bboozzoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement!

"bar": {"bar"},
"meh": {"foo", "bar"},
c.Check(dump, DeepEquals, map[string]string{
"foo": `[{"name":"foo","version":"1.0"}]`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/name/snap/ to match the json tags for Package struct

@zyga
Copy link
Collaborator

zyga commented Apr 6, 2018

Tests are not unit-happy:

FAIL: catalogrefresh_test.go:92: catalogRefreshTestSuite.TestCatalogRefresh

catalogrefresh_test.go:108:
    c.Check(dump, DeepEquals, map[string]string{
        "foo": `[{"name":"foo","version":"1.0"}]`,
        "bar": `[{"name":"bar","version":"2.0"}]`,
        "meh": `[{"name":"foo","version":"1.0"},{"name":"bar","version":"2.0"}]`,
    })
... obtained map[string]string = map[string]string{"bar":"[{\"snap\":\"bar\",\"version\":\"2.0\"}]", "foo":"[{\"snap\":\"foo\",\"version\":\"1.0\"}]", "meh":"[{\"snap\":\"foo\",\"version\":\"1.0\"},{\"snap\":\"bar\",\"version\":\"2.0\"}]"}
... expected map[string]string = map[string]string{"foo":"[{\"name\":\"foo\",\"version\":\"1.0\"}]", "bar":"[{\"name\":\"bar\",\"version\":\"2.0\"}]", "meh":"[{\"name\":\"foo\",\"version\":\"1.0\"},{\"name\":\"bar\",\"version\":\"2.0\"}]"}

EDIT: and I see Maciej found the same thing.

@chipaca chipaca force-pushed the snap-advice-command-versions-2 branch from 1dc9678 to 3e72368 Compare April 6, 2018 14:40
@codecov-io
Copy link

Codecov Report

Merging #4999 into master will increase coverage by 0.01%.
The diff coverage is 65.71%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4999      +/-   ##
==========================================
+ Coverage   79.11%   79.12%   +0.01%     
==========================================
  Files         478      478              
  Lines       35490    35507      +17     
==========================================
+ Hits        28078    28095      +17     
+ Misses       5191     5183       -8     
- Partials     2221     2229       +8
Impacted Files Coverage Δ
advisor/pkgfinder.go 75% <ø> (+25%) ⬆️
advisor/cmdfinder.go 80.95% <ø> (ø) ⬆️
store/store.go 81.44% <0%> (ø) ⬆️
advisor/backend.go 67.16% <67.64%> (+3.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d10562e...3e72368. Read the comment docs.

Copy link
Collaborator

@zyga zyga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zyga zyga merged commit b191ea5 into snapcore:master Apr 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants